#ifndef __ROB_COMMON_H__
#define __ROB_COMMON_H__

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

/* TRUE, FALSE symbol for Boolean types*/
#ifndef TRUE
#define TRUE (1u)
#endif
#ifndef FALSE
#define FALSE (0u)
#endif

#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline

#define PI 3.1415926535898f
#define RAD_TO_DEG 57.2957795131f
#define DEG_TO_RAD 0.0174532925199f

/* Robot Arm Configuration */
#define ROB_SERVO_NUM 6u
#define ROB_SENSOR_NUM 4u
#define ROB_MAX_TRAJECTORY_POINTS 100u

/* PWM Configuration */
#define ROB_PWM_PERIOD 20000u      /* 20ms period */
#define ROB_PWM_MIN 500u           /* 0.5ms min pulse */
#define ROB_PWM_MAX 2500u          /* 2.5ms max pulse */
#define ROB_PWM_CENTER 1500u       /* 1.5ms center pulse */

/* Data Type Definitions (following EASML style) */
typedef unsigned char boolean;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;

typedef int8_t sint8;
typedef int16_t sint16;
typedef int32_t sint32;
typedef int64_t sint64;

typedef float float32;
typedef double float64;

/* Robot Arm Status Codes */
typedef enum {
    ROB_STATUS_OK = 0u,
    ROB_STATUS_ERROR = 1u,
    ROB_STATUS_INVALID_PARAM = 2u,
    ROB_STATUS_OUT_OF_RANGE = 3u,
    ROB_STATUS_TIMEOUT = 4u,
    ROB_STATUS_BUSY = 5u
} Rob_Status_Type;

/* Robot Operating Modes */
typedef enum {
    ROB_MODE_MANUAL = 0u,
    ROB_MODE_AUTO = 1u,
    ROB_MODE_LEARNING = 2u,
    ROB_MODE_REPLAY = 3u,
    ROB_MODE_KINEMATICS = 4u
} Rob_Mode_Type;

/* Robot State Machine States */
typedef enum {
    ROB_STATE_INIT = 0u,
    ROB_STATE_IDLE = 1u,
    ROB_STATE_MOVING = 2u,
    ROB_STATE_ERROR = 3u,
    ROB_STATE_CALIBRATING = 4u
} Rob_State_Type;

#endif /* __ROB_COMMON_H__ */
